/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chess;
import   java.awt.*;
import   java.awt.event.*;

/**
 *
 * @author houfukude
 */
//负责创建黑色棋子的类：
class ChessPoint_black extends Canvas implements MouseListener{
      ChessPad chesspad = null;                    //棋子所在的棋盘。
      ChessPoint_black(ChessPad p){
          setSize(20,20);
          chesspad=p;
          addMouseListener(this);
      }
    @Override
      public void paint(Graphics g)              //绘制棋子的大小。
      {
          g.setColor(Color.black);
          g.fillOval(0,0,14,14);
      }
      public void mousePressed(MouseEvent   e){
          if(e.getModifiers()==InputEvent.BUTTON3_MASK)
          {
              chesspad.remove(this);               //当用鼠标右键点击棋子时，从棋盘中去掉该棋子（悔棋）。
              chesspad.棋子颜色=1;
              chesspad.text_2.setText("");
              chesspad.text_1.setText("请黑棋下子");
          }
    }
    public   void   mouseReleased(MouseEvent   e){}
    public   void   mouseEntered(MouseEvent   e)   {}
    public   void   mouseExited(MouseEvent   e)   {}
    public   void   mouseClicked(MouseEvent   e){
        if(e.getClickCount()>=2)
            chesspad.remove(this);                  //当用左键双击该棋子时，吃掉该棋子。
    }
  }
